<!-- 支付 -->
<!-- type:0  支付成功  1支付失败 -->
<template>
    <view class="payment">
		<view class="payment_box">
			<view class="payment_content" :class="{position : type == 0}">
				<view class="info_box">
					<view class="picture">
						<img :src="type == 0 ? info_box.success_img : info_box.fail_img" />
					</view>
					<view class="info">
						<view class="text" v-for="(item,index) in info_box.info" :key="index">
							<view class="left">{{ item.label }}</view>
							<view class="right">{{ item.value }}</view>
						</view>
						<view class="text" v-if="type == 1">
							<view class="left">失败原因</view>
							<view class="right">{{ info_box.fail_reason }}</view>
						</view>
					</view>
				</view>
				<view class="repayments" v-if="type == 1" @click="backPage">重新支付</view>
				<view class="button" @click="toPage(button_url)">返回首页</view>
			</view>
		</view>
	</view>
</template>
<script>
export default {
    components: {},
    data() {
        return {
			type: 1,			// 是否支付成功的状态  0：成功   1：失败
			info_box: {
				success_img: "/static/img/pay_success.png",
				fail_img: "/static/img/pay_failure.png",
				info: [
					{
						id: 0,
						label: "订单编号",
						value: "20200918170500001"
					},{
						id: 1,
						label: "下单时间",
						value: "2020-09-18 17:50:17"
					},{
						id: 2,
						label: "支付积分",
						value: "8800"
					},{
						id: 3,
						label: "备注",
						value: "无"
					}
				],
				fail_reason: "取消支付"
			},
			button_url: "/pages/home_index/index"
		};
    },
    computed: {},
    methods: {
		toPage(val) {
			uni.switchTab({
				url: val
			})
		},
		backPage() {
			uni.navigateBack({
				delta: 1
			})
		}
	},
	onLoad:function(option){
	},
    beforeCreate() {},
    created() {},
    beforeMount() {},
    mounted() {	
		if(this.type === 0){
			uni.setNavigationBarTitle({
				title: '支付成功'
			})
		}else {
			uni.setNavigationBarTitle({
				title: '支付失败'
			})
		}
	},
    beforeUpdate() {},
    updated() {},
    beforeDestroy() {},
    destroyed() {},
};
</script>
<style scoped lang='scss'>
@import "./index.scss";
</style>